package com.hibernate.chapter1;

import java.sql.Date;
import java.util.GregorianCalendar;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
//import org.hibernate.tool.hbm2ddl.SchemaExport;

public class TestEmployee {

	public static void main(String[] args) {
		AnnotationConfiguration config = new AnnotationConfiguration();
		config.addAnnotatedClass(Employee.class);
		config.configure("hibernate.cfg.xml");

		//new SchemaExport(config).create(true, true);
		SessionFactory factory = config.buildSessionFactory();
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		
		Employee julio = new Employee();
		//employee.setEmpId(101);
		julio.setEmpName("Julio Sandobalin");
		julio.setEmpEmailAddress("julio@mail.com");
		julio.setEmpPassword("julio");
		julio.setPermanent(true);
		julio.setEmpJoinDate(new GregorianCalendar(2011, 07, 10));
		julio.setEmpLoginTime(Date.valueOf("2011-07-10"));
		session.save(julio);

		Employee marcia = new Employee();
		//employee.setEmpId(101);
		marcia.setEmpName("Marcia Telpis");
		marcia.setEmpEmailAddress("marcia@mail.com");
		marcia.setEmpPassword("marcia");
		marcia.setPermanent(true);
		marcia.setEmpJoinDate(new GregorianCalendar(2011, 07, 10));
		marcia.setEmpLoginTime(Date.valueOf("2011-07-10"));
		session.save(marcia);
		
		session.getTransaction().commit();
	}
}
